<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>

	<p:ajaxStatus onstart="statusDialog.show();"
		onsuccess="statusDialog.hide();" />

	<p:growl id="messages" showDetail="true" showSummary="true" life="3000" />
	<h:form id="form">
		<table width="965" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td><table width="100%" border="0" cellspacing="2"
						cellpadding="0">
						<tr>
							<!-- 
		##############################################################################################################################
		
														CABEÇALHO SOLICITACAO
		
		##############################################################################################################################
		 -->
							<td width="25%" align="right"><h:outputLabel for="emissao"
									value="#{message.solicita_dt_emissao}" styleClass="LabelFont" /></td>
							<td width="5%"><p:calendar id="emissao" effect="slideDown"
									size="6" maxlength="8" disabled="true"
									value="#{solicitaTela.dataEmissao}" style="font-size: 13px;" /></td>
							<td width="2%"></td>
							<td colspan="2"><p:selectOneMenu
									value="#{solicitaTela.empresaSelecionada.filial}" effect="fade"
									style="font-size: 13px;" id="iFil">
									<f:selectItem itemLabel="" itemValue="" />
									<f:selectItems value="#{usuario.listaEmpresas}" var="empresa"
										itemLabel="#{empresa.descricao}" itemValue="#{empresa.filial}"
										style="font-size: 13px;" />
									<p:ajax global="false" />
								</p:selectOneMenu></td>
						</tr>
						<tr>
							<td align="right"><h:outputLabel for="requis"
									value="#{message.solicita_unid_requis}" styleClass="LabelFont" /></td>
							<td width="5%"><p:inputText id="requis" required="true"
									size="8" maxlength="5"
									value="#{solicitaTela.unidadeRequisicao.codigo}"
									style="font-size: 13px;"
									validator="#{solicitaTela.validaCampos}"
									requiredMessage="#{message.msg_requerido}">
									<p:ajax event="blur" update=":growl,:form:descRequis,@this"
										process="@this" global="false" />
								</p:inputText></td>
							<td width="2%"><p:commandButton id="pesqUni"
									icon="ui-icon-search" title="#{message.botao_pesquisar}"
									type="button" styleClass="ButtonPesq" onclick="dlg2.show()"
									global="false" /></td>
							<td><p:inputText id="descRequis" size="50" readonly="true"
									value="#{solicitaTela.unidadeRequisicao.descricao}"
									style="font-size: 13px;" /></td>
						</tr>
						<tr>
							<td align="right"><h:outputLabel for="comprador"
									value="#{message.solicita_comprador}" styleClass="LabelFont" /></td>
							<td width="5%"><p:inputText size="8" maxlength="3"
									value="#{solicitaTela.comprador.codigo}" id="comprador"
									required="true" style="font-size: 13px;"
									validator="#{solicitaTela.validaCampos}"
									binding="#{solicitaTela.uiCompradorInput}"
									requiredMessage="#{message.msg_requerido}">
									<p:ajax event="blur"
										update=":growl,:form:descComp,:form:comprador" process="@this"
										global="false" />
								</p:inputText></td>
							<td width="2%"><p:commandButton id="pesqComp" type="button"
									icon="ui-icon-search" title="#{message.botao_pesquisar}"
									styleClass="ButtonPesq" onclick="dlg3.show()" global="false" /></td>
							<td><p:inputText size="50" id="descComp" readonly="true"
									value="#{solicitaTela.comprador.nome}" style="font-size: 13px;" /></td>
						</tr>
					</table></td>
			</tr>
			<tr>
				<td><p:separator /></td>
			</tr>
			<tr>
				<!-- 
		##############################################################################################################################
		
														CAMPOS ITENS SOLICITACAO
		
		##############################################################################################################################
		 -->
				<td align="left">
					<div align="left" class="DivProd">
						<h:outputLabel for="iProd" value="#{message.produto_produto} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iProd" value="#{solicitaTela.produto.codigo}"
							size="8" style="font-size: 13px;"
							validator="#{solicitaTela.validaCampos}" required="true"
							requiredMessage="#{message.msg_requerido}">
							<p:ajax event="blur"
								update=":growl,:form:iDesc,:form:iUm,:form:iProd,:form:iNec,:form:iArm,:form:iFil"
								process="@this" global="false" />
						</p:inputText>
						<p:commandButton id="pesqProd" icon="ui-icon-search"
							title="#{message.botao_pesquisar}" styleClass="ButtonPesq"
							onclick="dlg4.show()" global="false" type="button" />
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iProd" value="#{message.produto_descricao} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iDesc" value="#{solicitaTela.produto.descricao}"
							size="20" style="font-size: 13px;">

						</p:inputText>
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iUm" value=" #{message.produto_um} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iUm"
							value="#{solicitaTela.produto.segUniMedida.equals('') ? solicitaTela.produto.unidMedida : solicitaTela.produto.segUniMedida}"
							readonly="true" size="1" style="font-size: 13px;" />
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iQtde" value=" #{message.produto_quant} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iQtde" value="#{solicitaTela.produto.quantidade}"
							size="6" style="font-size: 13px;" required="true"
							converterMessage="#{message.msg_conversao}"
							requiredMessage="#{message.msg_requerido}" />
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iNec"
							value=" #{message.produto_dt_necessidade} "
							styleClass="LabelFont" />
						<br />
						<p:inputMask id="iNec" value="#{solicitaTela.necessidade}"
							size="5" maxlength="8" style="font-size: 13px;"
							validator="#{solicitaTela.validaCampos}" mask="99/99/99"
							required="true" requiredMessage="#{message.msg_requerido}">
							<p:ajax event="blur" update=":growl,:form:iNec" process="@this"
								global="false" />
						</p:inputMask>
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iArm" value="#{message.produto_armazem} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iArm" value="#{solicitaTela.produto.local}"
							maxlength="4" size="1" style="font-size: 13px;"
							validator="#{solicitaTela.validaCampos}" required="true"
							requiredMessage="#{message.msg_requerido}">
							<p:ajax event="blur" update=":growl,:form:iArm" process="@this"
								global="false" />
						</p:inputText>
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iCc" value="#{message.produto_cc} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iCc" value="#{solicitaTela.centroCusto.codigo}"
							size="7" maxlength="9" style="font-size: 13px;"
							validator="#{solicitaTela.validaCampos}" required="true"
							requiredMessage="#{message.msg_requerido}">
							<p:ajax event="blur" update=":growl,:form:iCc" process="@this"
								global="false" />
						</p:inputText>
						<p:commandButton id="pesqCc" icon="ui-icon-search" type="button"
							title="#{message.botao_pesquisar}" styleClass="ButtonPesq"
							onclick="dlg5.show()" global="false" />
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iOp" value="#{message.produto_op} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iOp" value="#{solicitaTela.produto.ordemProd}"
							size="9" style="font-size: 13px;">
							<p:ajax event="blur" update=":growl,:form:iOp" process="@this"
								global="false" />
						</p:inputText>
					</div>
					<div align="left" class="DivProd">
						<h:outputLabel for="iObs" value="#{message.produto_observa} "
							styleClass="LabelFont" />
						<br />
						<p:inputText id="iObs" value="#{solicitaTela.produto.observacao}"
							size="15" style="font-size: 13px;" maxlength="250"/>
					</div>
					<div align="left" class="DivAdic">
						<p:commandButton id="adProd" icon="ui-icon-plus"
							title="#{message.botao_adicionar}" styleClass="ButtonPesq"
							update="prods :messages @parent"
							action="#{solicitaTela.adiciona}" global="false">
							<p:collector value="#{solicitaTela.produto}"
								addTo="#{solicitaTela.listaProd}" />
						</p:commandButton>
					</div> <!-- 
		##############################################################################################################################
		
													TABELA COM OS ITENS SOLICITACAO INSERIDOS
		
		##############################################################################################################################
		 -->
					<div align="left" class="DivAdic"
						style="clear: both; font-size: 10px;">

						<p:outputPanel id="prods">
							<p:dataTable id="prodTable" value="#{solicitaTela.listaProd}"
								var="prod" editable="true"
								emptyMessage="#{message.msg_semvalores}">

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{message.produto_produto}"
											styleClass="LabelGrid" />
									</f:facet>
									<h:outputText value="#{prod.codigo}" styleClass="LabelGrid" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{message.produto_descricao}"
											styleClass="LabelGrid" />
									</f:facet>
									<h:outputText value="#{prod.descricao}" styleClass="LabelGrid" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{message.produto_um}"
											styleClass="LabelGrid" />
									</f:facet>
									<h:outputText value="#{prod.unidMedida}" styleClass="LabelGrid" />
								</p:column>

								<p:column headerText="#{message.produto_quant}"
									styleClass="LabelGrid">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{prod.quantidade}"
												styleClass="LabelGrid" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{prod.quantidade}"
												styleClass="LabelGrid" style="font-size: 13px;" size="6"
												required="true" converterMessage="#{message.msg_conversao}" />
										</f:facet>
									</p:cellEditor>
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{message.produto_dt_necessidade}"
											styleClass="LabelGrid" />
									</f:facet>
									<h:outputText value="#{prod.necessidade}"
										styleClass="LabelGrid">
										<f:convertDateTime pattern="dd/MM/yy" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{message.produto_armazem}"
									styleClass="LabelGrid">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{prod.local}" styleClass="LabelGrid" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{prod.local}" styleClass="LabelGrid"
												style="font-size: 13px;" required="true" size="1" id="iArm2"
												maxlength="4" validator="#{solicitaTela.validaCampos}" />
										</f:facet>
									</p:cellEditor>
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{message.produto_cc}"
											styleClass="LabelGrid" />
									</f:facet>
									<h:outputText value="#{prod.centroCusto.codigo}"
										styleClass="LabelGrid" />
								</p:column>

								<p:column headerText="#{message.produto_op}"
									styleClass="LabelGrid">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{prod.ordemProd}"
												styleClass="LabelGrid" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{prod.ordemProd}" styleClass="LabelGrid"
												style="font-size: 13px;" size="9" />
										</f:facet>
									</p:cellEditor>

								</p:column>

								<p:column headerText="#{message.produto_observa}"
									styleClass="LabelGrid">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{prod.observacao}"
												styleClass="LabelGrid" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{prod.observacao}"
												styleClass="LabelGrid" style="font-size: 13px;" size="15" />
										</f:facet>
									</p:cellEditor>
								</p:column>
								<p:column>
									<p:rowEditor />
								</p:column>
								<p:column>
									<p:commandButton update=":form:prods :messages"
										process=":form:prods" icon="ui-icon-minus"
										styleClass="ButtonRem" global="false" id="butRem">
										<p:collector value="#{prod}"
											removeFrom="#{solicitaTela.listaProd}" />
										<p:tooltip for="butRem" value="#{message.msg_remover_item}"
											showEffect="fade" hideEffect="fade" />
									</p:commandButton>
								</p:column>
							</p:dataTable>
						</p:outputPanel>
					</div>
					<div class="DivButton">
						<p:commandButton id="confirmar" value="#{message.botao_concluir}"
							update="@form,:growl,:fNumSol" action="#{solicitaTela.gravar}"
							immediate="true" icon="ui-icon-disk" />
						<p:commandButton id="cancelar" value="#{message.botao_cancelar}"
							update="@form,:growl" onclick="dlg1.hide()" global="false"
							action="#{solicitaTela.cancelaGravacao}" immediate="true"
							icon="ui-icon-close" />
					</div>
				</td>
			</tr>
		</table>

		<div class="DivCheck">
			<h:outputText value="#{message.msg_checkBox} "
				style="font-size: 13px;" />
			<p:selectBooleanCheckbox value="#{solicitaTela.checkFecha}"
				style="vertical-align: middle;">
				<p:ajax global="false" />
			</p:selectBooleanCheckbox>
		</div>
	</h:form>


	<!-- 
		##############################################################################################################################
		
														MODELPANEL ERRO MICROSIGA
		
		##############################################################################################################################
	-->

	<p:dialog header="#{message.msg_header_aviso}" widgetVar="dlgErro"
		height="350" width="550" resizable="false" showEffect="fadein"
		style="font-size: 18px;" appendToBody="true" modal="true">
		<h:form id="formErro">
			<div style="font-size: 13px;">
				<p:inputTextarea style="width:480px; height:280 "
					value="#{solicitaTela.numSolicitacao}" readonly="true" />
			</div>
		</h:form>
	</p:dialog>
</h:body>
</html>